org.mentalsmash.asksusanna.gui.Tooltip = function(phrase,span,word,color) {
	
	function addCommas(nStr) {
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + '.' + '$2');
		}
		return x1 + x2;
	}
	
	
	var toolTip = $('<div></div>');
	toolTip.addClass('tooltip');
	toolTip.fadeIn();
	var pos = span.offset();
	//toolTip.css('left', pos.left - 130 + (span.width() / 2));
	//toolTip.css('top', pos.top + 90);
	

	var wp = $('<p class="word-stats"></p>');
	toolTip.append(wp);

	var subphrases = word.getPhrases();
	var phrasesList = $('<ul></ul>');
	phrasesList.append('<li class="tableHead" style="background-color:' + color + ';">'+
							'<span class="tpPhrase">'+
								'<strong>Phrases</strong>'+
							'</span>'+
							'<span class="tpValue">'+
								'<strong>Results</strong>'+
							'</span>'+
						'</li>');


	$(subphrases).each(function(i, phr){
		var li = $('<li></li>');
		var hits = phrase.getSubphraseHits(phr);

		li.html('<span class="tpPhrase">'+
					'<em>'+phr+'</em>'+
				'</span>'+
				'<span class="tpValue">'+
					'<strong>'+addCommas(hits)+'</strong>'+
				'</span>');
		phrasesList.append(li);
	});



	toolTip.append(phrasesList);


	return toolTip;
}